package com.cd2cd.mapper;

import com.cd2cd.domain.ProDatabase;
import com.cd2cd.mapper.gen.SuperProDatabaseMapper;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ProDatabaseMapper extends SuperProDatabaseMapper {

    @Select("select db_name from pro_database where id = (select database_id from pro_table where id=#{superId})")
    @ResultType(String.class)
    String selectDbNameByTableId(@Param("superId") Long superId);

    @Select("select db_name from pro_database where db_name_module = 'true' and id = (select database_id from pro_table where id=#{superId})")
    @ResultType(String.class)
    String queryDbNameByTableIdAndDbNameModule(Long superId);


    @Select("select * from pro_database where id in (select database_id from pro_project_database_rel where project_id = #{projectId})")
    @ResultMap("BaseResultMap")
    List<ProDatabase> selectByProjectId(@Param("projectId") Long projectId);
}